****
** REPLICATION CODE FOR "Sociopolitical and psychological correlates of COVID-19 vaccine hesitancy..."
****

********************************************************************************
****
** Get Data
****

clear
set more off
use ".../replication_data.dta"


********************************************************************************
****
** Recode and Construct Variables
****

*Gender (female)
gen female = gender
recode female (1=0) (0=1)
sum female

*Race
gen race = . 
replace race = 1 if race_1 == 1
replace race = 2 if race_2 == 1
replace race = 3 if race_4 == 1
replace race = 4 if race_5 == 1
replace race = 5 if race_6 == 1
label define racel 1 "White" 2 "Black" 3 "Asian" ///
	4 "Native American" 5 "Other Race"
label values race racel
gen white = 0
replace white = 1 if race_1 == 1
sum white
gen black = 0
replace black = 1 if race_2 == 1
sum black
gen hispanic = 0
replace hispanic = 1 if q208 == 1
sum hispanic

*Age
gen age = 2021 - yearborn
gen agesq = age^2
sum age agesq

*Household income
gen income = inc
sum inc

*Party identification
gen pid = .
replace pid = -3 if poldem == 1
replace pid = -2 if poldem == 2
replace pid = -1 if polcloser == 2
replace pid = 0 if polcloser == 3
replace pid = 1 if polcloser == 1
replace pid = 2 if polrepub == 2
replace pid = 3 if polrepub == 1
gen pidstrength = abs(pid)
gen rep = .
replace rep = 0 if pid < 0
replace rep = 1 if pid > 0 & pid < .
replace pid = pid + 4
sum pid

*Ideology
gen ideo = polideo - 4
gen ideostrength = abs(ideo)
gen conserv = .
replace conserv = 0 if ideo < 0
replace conserv = 1 if ideo > 0 & ideo < .
replace ideo = ideo + 4
sum ideo

*Interest in politics
gen interest = polint + 1
sum interest

*Were you ever ill from COVID-19 during the pandemic?
gen covillalt = covill
recode covillalt (2=1) (3=1)
sum covillalt

*Have you personally received at least one dose of a COVID-19 vaccine?
sum covvax
tab covvax
	*create 1 = not vaxed, 0 = vaxed
gen NO_covvax=.
replace NO_covvax=1 if covvax==0
replace NO_covvax=0 if covvax==1
tab NO_covvax
tab NO_covvax covvax
sum NO_covvax

*Which of the following best describes how you feel about the COVID-19 vaccine?
sum covview

*Novax
gen novax = .
replace novax = 1 if covvax == 1
replace novax = 2 if covvax == 0 & covview == 1
replace novax = 3 if covvax == 0 & covview == 2
replace novax = 4 if covvax == 0 & covview == 3
replace novax = 5 if covvax == 0 & covview == 4
sum novax

*Were you working outside the home during the COVID-19 lockdown? (1 = yes, 0 = no or na bc not employed outside home)
recode empoutside (2=0)
sum empoutside

*How has the Coronavirus pandemic changed your employment status?
gen empstatus = .
replace empstatus = 0 if empchg_1 == 1
replace empstatus = 0 if empchg_3 == 1
replace empstatus = 1 if empchg_2 == 1
replace empstatus = 1 if empchg_4 == 1
replace empstatus = 1 if empchg_5 == 1
replace empstatus = 1 if empchg_6 == 1
replace empstatus = 1 if empchg_7 == 1
sum empstatus

*COVID vaccine misinformation
factor covvaxinfo_1-covvaxinfo_5, ipf
alpha covvaxinfo_1-covvaxinfo_5, gen(covvaxinfo)
sum covvaxinfo

*COVID conspiracy beliefs
gen cexaggerate = covcons_1
gen cpurpose = covcons_2
gen deaths = covcons_3
gen covidvaxx = covcons_4
gen cellphone = covcons_5
gen billgates = covcons_6
gen tracking = covcons_7
foreach v of var cpurpose-tracking{
	gen belief_`v' = 0
	replace belief_`v' = 1 if `v' > 3 & `v' < .
}
egen covnumber = rowtotal(belief_cpurpose-belief_tracking)
factor cpurpose-tracking, ipf
alpha cpurpose-tracking, gen(covidcon)
sum covidcon

*Feeling thermometer
gen trumpft = therm_1

*Conspiratorial thinking
factor ctscale_1-ctscale_4, ipf
alpha ctscale_1-ctscale_4, gen(conthink)
sum conthink

*Non-COVID conspiracy beliefs
gen goodevil = misc_2

*Machiavellianism
factor mach_1-mach_4, ipf
alpha mach_1-mach_4, gen(manipulate)
sum manipulate

*Narcissism
factor narc_1-narc_4, ipf
alpha narc_1-narc_4, gen(narcissism)
sum narcissism

*Psychopathy
factor psyc_1-psyc_4, ipf
alpha psyc_1-psyc_4, gen(psychopathy)
sum psychopathy

*Dark triad summary
factor mach_1-mach_4 narc_1-narc_4 psyc_1-psyc_4, ipf
alpha mach_1-mach_4 narc_1-narc_4 psyc_1-psyc_4, gen(darktriad)
sum darktriad

*Populism
factor pop_1-pop_4, ipf
alpha pop_1-pop_4, gen(populism)
sum populism

*Anti-establishment
factor pop_1-pop_4 goodevil ctscale_1-ctscale_4, ipf
alpha pop_1-pop_4 goodevil ctscale_1-ctscale_4, gen(antiestab)
sum antiestab

*Perceived victimhood
factor victim_1-victim_4, ipf
alpha victim_1-victim_4, gen(victimhood)
sum victimhood

*Science literacy
gen correct1 = .
replace correct1 = 1 if scilit_1 == 1
replace correct1 = 0 if scilit_1 == 0

gen correct2 = .
replace correct2 = 1 if scilit_2 == 0
replace correct2 = 0 if scilit_2 == 1

gen correct3 = .
replace correct3 = 1 if scilit_3 == 1
replace correct3 = 0 if scilit_3 == 0

gen correct4 = .
replace correct4 = 1 if scilit_4 == 1
replace correct4 = 0 if scilit_4 == 0

gen correct5 = .
replace correct5 = 1 if scilit_5 == 0
replace correct5 = 0 if scilit_5 == 1

gen correct6 = .
replace correct6 = 1 if scilit_6 == 1
replace correct6 = 0 if scilit_6 == 0

gen correct7 = .
replace correct7 = 1 if scilit_7 == 0
replace correct7 = 0 if scilit_7 == 1

gen correct8 = .
replace correct8 = 1 if scilit_8 == 0
replace correct8 = 0 if scilit_8 == 1

gen correct9 = .
replace correct9 = 1 if scilit_9 == 1
replace correct9 = 0 if scilit_9 == 0

gen correct10 = .
replace correct10 = 1 if scilit_10 == 1
replace correct10 = 0 if scilit_10 == 0

gen correct11 = .
replace correct11 = 1 if scilit_11 == 0
replace correct11 = 0 if scilit_11 == 1

alpha correct1-correct11
egen sciencelit = rowtotal(correct1-correct11)
sum sciencelit

*Anti-intellectualism/trust
factor trust_sci trust_doc trust_pho, ipf
alpha trust_sci trust_doc trust_pho, gen(trustsci)
sum trustsci

*I have confidence in the scientific community
sum confsci

*How physically strong are you compared to other people from your gender?
sum strength

*Were you working outside the home during the COVID-19 lockdown?
recode empoutside (2=.)
sum empoutside

*Socioeconomic ladder
gen ladder = .
replace ladder = 1 if ladder_1 == "On"
replace ladder = 2 if ladder_2 == "On"
replace ladder = 3 if ladder_3 == "On"
replace ladder = 4 if ladder_4 == "On"
replace ladder = 5 if ladder_5 == "On"
replace ladder = 6 if ladder_6 == "On"
replace ladder = 7 if ladder_7 == "On"
replace ladder = 8 if ladder_8 == "On"
replace ladder = 9 if ladder_9 == "On"
replace ladder = 10 if ladder_10 == "On"
sum ladder

*Importance of religion
gen religimp = relimp + 1
sum rel_right rel_protect religimp

*Attendance of religious services
gen attend = (relserv * -1) + 7
recode attend (0=.)
sum attend

*Outside of attending religious services, how often do you pray? 
recode relpray (-99=.)
sum relpray

*Religiosity
factor religimp rel_right rel_protect attend relpray, ipf
alpha religimp rel_right rel_protect attend relpray, gen(religiosity)
sum religiosity

*Religious affiliation
gen denom = .
replace denom = 1 if relcurr == 1
replace denom = 2 if relcurr == 2
replace denom = 3 if relcurr == 3
replace denom = 3 if relcurr == 4
replace denom = 4 if relcurr == 5
replace denom = 4 if relcurr == 6
replace denom = 4 if relcurr == 7
replace denom = 4 if relcurr == 8
replace denom = 5 if relcurr == 9
replace denom = 5 if relcurr == 10
replace denom = 5 if relcurr == 11
replace denom = 6 if relcurr == 12
label define denoml 1 "Protestant" 2 "Catholic" 3 "Other Christian" ///
	4 "Other Religion" 5 "None" 6 "Something Else"
label values denom denoml

*Would you describe yourself as a "born-again" or evangelical Christian, or not? 
gen bornagain = 0
replace bornagain = 1 if bornagn == 1
sum bornagain

*Perceived stress
replace pss4_2 = (pss4_2 * -1) + 4
replace pss4_3 = (pss4_3 * -1) + 4
factor pss4_1-pss4_4, ipf
alpha pss4_1-pss4_4, gen(stress)
sum stress

*Empathy
replace eq8_5 = (eq8_5 * -1) + 3
replace eq8_6 = (eq8_6 * -1) + 3
replace eq8_7 = (eq8_7 * -1) + 3
replace eq8_8 = (eq8_8 * -1) + 3
factor eq8_1-eq8_8, ipf
alpha eq8_1-eq8_8, gen(empathy)
sum empathy

*Compassion
factor compassion_1-compassion_5, ipf
alpha compassion_1-compassion_5, gen(compassion)
sum compassion

*Frequency of social media use
gen facebook = social_fb
gen twitter = social_tw
gen instagram = social_insta
gen youtube = social_yt
factor facebook-youtube, ipf
alpha facebook-youtube, gen(socialmedia)
sum socialmedia

*Conflict scale
factor conflict_3-conflict_12, ipf
alpha conflict_3-conflict_12
egen conflict = rowtotal(conflict_3-conflict_12)
sum conflict


********************************************************************************
****
** Sociodemographics of Sample
****

sum age, detail
sum income, detail
sum female
sum white
sum black
sum hispanic
sum pid
sum ideo 
sum attend


********************************************************************************
****
** Binary Logit Model-Building: NO_covaxx (1 = not vaxed, 0 = vaxed)
****	

*Baseline sociodemographic model
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic	

*COVID experience
logit NO_covvax covillalt empoutside empstatus

*Information environment
logit NO_covvax covvaxinfo covidcon socialmedia
	
*Trust and science literacy
logit NO_covvax sciencelit trustsci confsci	
	
*Political orientations
logit NO_covvax pid ideo antiestab trumpft interest	
	
*Psychological traits
logit NO_covvax manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength

*Full model
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength

*For supplementary analysis: full model minus covid misinfo and covid CTs
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength
	
*Figures from full model
	*run full model
logit covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strengt
	
	*age and age^2
		*20-years-old
margins, at(age=(20) agesq=(400)) atmeans		
		*30
margins, at(age=(30) agesq=(900)) atmeans		
		*40
margins, at(age=(40) agesq=(1600)) atmeans		
		*50
margins, at(age=(50) agesq=(2500)) atmeans		
		*60
margins, at(age=(60) agesq=(3600)) atmeans		
		*70
margins, at(age=(70) agesq=(4900)) atmeans	
		*80
margins, at(age=(80) agesq=(6400)) atmeans
	
	*income
margins, at(inc=(1(1)7)) atmeans
	
	*race
		*ib1.race
margins ib1.race, atmeans	
		*hispanic
margins, at(hispanic=0) atmeans	
margins, at(hispanic=1) atmeans	
	
	*covvaxinfo
margins, at(covvaxinfo=(1(1)5)) atmeans

	*trustsci
margins, at(trustsci=(1(1)7)) atmeans
	
	*confsci
margins, at(confsci=(1(1)5)) atmeans
	
*Re-run the models above for log odds
	*baseline sociodemographic model
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic, or	

	*COVID experience
logit NO_covvax covillalt empoutside empstatus, or

	*information environment
logit NO_covvax covvaxinfo covidcon socialmedia, or
	
	*trust and science literacy
logit NO_covvax sciencelit trustsci confsci, or
	
	*political orientations
logit NO_covvax pid ideo antiestab trumpft interest, or
	
	*psychological traits
logit NO_covvax manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, or

	*full model
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strengt, or

	*for supplementary analysis: full model minus covid misinfo and covid CTs
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, or
	
	
********************************************************************************
****
** MLOGITS for Type of Vax Reluctance
****

*Baseline sociodemographic model	
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic, baseoutcome(1)			

*COVID experience
mlogit novax covillalt empoutside empstatus, baseoutcome(1)	

*Information environment
mlogit novax covvaxinfo covidcon socialmedia, baseoutcome(1)
	
*Trust and science literacy
mlogit novax sciencelit trustsci confsci, baseoutcome(1)	
	
*Political orientations
mlogit novax pid ideo antiestab trumpft interest, baseoutcome(1)	
	
*Psychological traits
mlogit novax manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, baseoutcome(1)

*Full model
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, baseoutcome(1)

*For supplementary analysis: full model minus covid misinfo and covid CTs
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength
	
*Re-run above for relative risk ratios
	*baseline sociodemographic model	
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic, baseoutcome(1) rrr

	*COVID experience
mlogit novax covillalt empoutside empstatus, baseoutcome(1)	

	*information environment
mlogit novax covvaxinfo covidcon socialmedia, baseoutcome(1)
	
	*trust and science literacy
mlogit novax sciencelit trustsci confsci, baseoutcome(1)
	
	*political orientations
mlogit novax pid ideo antiestab trumpft interest, baseoutcome(1)
	
	*psychological traits
mlogit novax manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, baseoutcome(1)

	*full model
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, baseoutcome(1)

	*for supplementary analysis: full model minus covid misinfo and covid CTs
mlogit novax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength
	

********************************************************************************

****
** Power analysis
****

* Estimate full NO_covaxx model
logit NO_covvax female age agesq edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength, or

* Mean and 1SD above mean for age
sum age
di 47.86423 + 17.58118 

* Predicted probability for mean and 1SD above mean for age
margins, at(stress=47.86423)
margins, at(stress=65.44541)

* Find multiple corr between age and all other predictors
reg age female edu inc ladder religiosity ib5.denom bornagain ib1.race hispanic ///
covillalt empoutside empstatus ///
covvaxinfo covidcon socialmedia ///
sciencelit trustsci confsci ///
pid ideo antiestab trumpft interest ///
manipulate narcissism psychopathy victimhood stress empathy compassion conflict strength

* Power analysis
powerlog, p1(.5483818) p2(.6418667) alpha(.05) rsq(0.5128)
